<template>
	<view>
		<!-- 头部标题 -->
		<view class="cu-bar bg-white">
			<view class="action sub-title">
				<text class="text-xl text-bold text-green">发布签到</text>
				<text class="bg-green"></text>
				<!-- last-child选择器-->
			</view>
		</view>
		<!-- 头部标题 end -->
		
		<!-- 内容区域 -->
		<view class="" style="width: 100%;">
			
			<view class="bg-white padding">
				<text style="color: #000000;font-weight: 550;">注:签到说明(点击开始签到持续30分钟)过后无效</text>
			</view>
			
			<view class="padding-xl">
				<button  @click.native="make()" class="cu-btn block bg-gradual-green margin-tb-sm lg">
					<text :class="  statusButton ? 'cuIconfont-spin cuIcon-loading2' : 'cuIconfont-spin' "></text> {{statusButton ? '签到开启中...' : '开启签到'}}
					</button>
			</view>
			
		</view>
		<!-- end -->
		
		
	</view>
</template>

<script>
	var _this;
	export default {
		data() {
			return {
				statusButton:false,//按钮状态(是否正在提交中...)
				classId:"",//课堂id
			}
		},
		methods: {
			// 签到
			make:function(){
				_this.statusButton = true;
				uni.request({
					url:_this.api + "Qian/create",
					data:{
						clazzId:_this.classId
					},
					header:{
						 "content-type":"application/x-www-form-urlencoded"
					},
					method:"POST",
					success: (res) => {
						_this.statusButton = false//关闭
						
						if(res.data.data == 200){
							uni.showToast({
								title:res.data.message,
								duration:1000,
								icon:"success"
							})
						}else{
							uni.showToast({
								title:res.data.message,
								duration:1000,
								icon:"success"
							})
						}
						console.log(res)
					},
					fail: (err) => {
						uni.showToast({
							title:"签到失败！请稍后在试~~",
							duration:1000,
							icon:"none"
						})
					}
					
				})
			}
		},
		onLoad(optins) {
			_this = this;
			_this.classId = optins.classId;
		}
	}
</script>

<style>

</style>
